import re

class Solution:
    def isPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        if len(s) == 0:
            return True

        s = re.sub(r'[^A-Za-z0-9]', '', s)
        s = re.sub(r'[A-Z]', lambda x: x.group(0).lower(), s)

        return s == s[::-1]
        

s = Solution()
print('ss', s.isPalindrome("0P"))
print('ss', s.isPalindrome("A man, a plan, a canal: Panama"))
print('ss', s.isPalindrome("race a car"))

